#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>

#include "myButton.h"
#include "serialconnection.h"
#include "pagehumiture.h"

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    PAGEHUMITURE *humiture;

    QPushButton *btnScreenShot;

    void layoutMainWindow();
    void newFunctionPage(QString name, QWidget* functionPage);
    void sendData(QByteArray sendBuf);

    enum menuOperation{
        Add,
        Show,
        Delete
    }myMenuOperation;

    void updateMenu(menuOperation opt, QString name,int index);
    void addButtonToMenu(QString name);
    void toggleButtonInMenu(int pageIndex);

public:
    QStackedWidget *stackedPage;
    QHBoxLayout *layoutMenuBar;
    QStringList *listFunctionPage;
    QVector <QWidget*> listMenuIndecator;

    serialConnection *linkToHardware;
private:
    QPushButton *debug;
    QLabel *state;
    QTimer *statetime;
private slots:
    void appQuit() {qApp->quit();}
    void switchFunctionPage(QString);
    void takePhoto();
    void readData();
    void sendCmd();
    void toUpdate();
    void set_debug();
    void time_over() {state->hide();}
    void widgetInfoHide(){humiture->widgetInfo->hide();}
};

#endif // MAINWINDOW_H
